
# 定义动物类Animal
class Animal:
    # 定义构造方法，初始化所有成员变量
    def __init__(self, name, age, sex, legNum, weight):
        self.name = name
        self.age = age
        self.sex = sex
        self.legNum = legNum
        self.weight = weight

    # 定义eating方法，输出Animal eating
    def eating(self, food):
        print("Animal eating", food)

    # 重写__str__方法，返回所有成员变量的str类型数据
    def __str__(self):
        return "name: " + self.name + ", age: " + str(self.age) + ", sex: " + self.sex + ", legNum: " + str(
            self.legNum) + ", weight: " + str(self.weight)


